using UnityEngine;

public class ShowInterstitial : MonoBehaviour
{
	private int count;

	private void Start()
	{
		if (PlayerPrefs.GetInt("tmp") != 7)
		{
			Preload();
			count = PlayerPrefs.GetInt("Count2");
			count++;
			if (count >= 3 && Time.time - AdvertisementHandler.lastTime > 80f && JavaMessageHandler.interstitialPreloaded)
			{
				AdvertisementHandler.ShowPreloadedInterstitial(rewarded: false);
				JavaMessageHandler.interstitialPreloaded = false;
				Invoke("Preload", 1f);
				count = 0;
			}
			if (count < 0)
			{
				count = 0;
			}
			PlayerPrefs.SetInt("Count2", count);
		}
		if (!JavaMessageHandler.rewardedInterstitialPreloaded)
		{
			AdvertisementHandler.PreloadRewardedInterstitial();
		}
	}

	private void Preload()
	{
		if (!JavaMessageHandler.interstitialPreloaded)
		{
			AdvertisementHandler.PreloadInterstitial();
		}
	}
}
